<?php
class ymdian_applyControl extends  skymvc{
	
	public function __construct(){
		parent::__construct();
	}
	
	public function onDefault(){
		$sc_id=get('sc_id','i');
		$sc=M("site_city")->selectRow("sc_id=".$sc_id);
		if($sc){			 
			$scparent=M("site_city")->selectRow("sc_id=".$sc['pid']);
		}
		$shop=M("ymdian")->selectRow("sc_id=".$sc_id);
		$this->smarty->assign(array(
			"site_city"=>$sc,
			"shop"=>$shop,
			"scparent"=>$scparent
		));
		$this->smarty->display("ymdian_apply/index.html");
	}
	
	public function onSave(){
		$data=M('ymdian_apply')->postData();
		foreach($data as $v){
			if(!$v){
				$this->goAll("请填写完成资料",2);
			}
		}
		$data['dateline']=time();
		$data['siteid']=SITEID;
		if(M('ymdian_apply')->selectRow(" sc_id=".intval($data['sc_id'])." AND telephone='".$data['telephone']."' ")){
			$this->goAll("你已经申请过了",1);
		}
		M('ymdian_apply')->insert($data);
		$this->goAll("申请成功",0);
	}
		
}

?>